﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;

namespace sdamarketing
{
    public class news
    {
        // dodavanje na nova vest
        public void insertVest(int idUser, String sodrzina, String DT)
        {
            SqlConnection connection = ConnectionMenager.GetConnection();
            
            String sql = "INSERT INTO News (idUser, sodrzina, datum) VALUES ('" + idUser + "', '" + sodrzina + "', '" + DT + "')";

            SqlCommand command = new SqlCommand(sql, connection);

            command.ExecuteNonQuery();
            connection.Close();
        }

        public DataSet getAllNews()
        {
            DataSet dataSet = new DataSet();
            String sql = "SELECT * FROM News";

            SqlConnection connection = ConnectionMenager.GetConnection();
            SqlCommand command = new SqlCommand(sql, connection);
            command.CommandType = CommandType.Text;

            SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
            dataAdapter.Fill(dataSet, "News");

            connection.Close();
            return dataSet;
        }

        

    }
}